package com.xiaowu.datajpa.dao;


import com.xiaowu.datajpa.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface StudentRepository extends JpaRepository<Student,Integer> {

    /**
     * 根据姓名模糊查询
     * @param name
     * @return
     */
    List<Student> findByNameLike(String name);

    /**
     * 根据姓名和密码查询
     * @param name
     * @param password
     * @return
     */
    List<Student> findByNameAndPassword(String name, String password);

    Student findByStunumber(String stunumber);

    @Modifying
    @Query("UPDATE tb_student s SET s.password = ?1 WHERE s.id IN (?2)")
    void updatePassword(String newPassword, List<Integer> ids);
}
